package com.coding.service.impl;

import com.coding.base.pojo.BaseModel;
import com.coding.dao.MileageDao;
import com.coding.dao.UserDao;
import com.coding.pojo.Mileage;
import com.coding.pojo.User;
import com.coding.service.MileageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @auther wangchenghao
 * @date 2020/8/11
 **/
@Service
public class MileageImpl implements MileageService {
    @Autowired
    MileageDao mileageDao;
    @Autowired
    UserDao userDao;
    @Override
    public void getUserMileage(int user_id, BaseModel baseModel) throws Exception {
        User user = userDao.getuserbyuser_id(user_id);
        if (user == null) {
            baseModel.setFailure("该用户不存在，请检查账号是否正确");
            return;
        }
        List<Mileage> mileageList=mileageDao.selectByUser(user_id);
        if (mileageList==null){
            baseModel.setFailure("该用户暂无里程");
        }else{
            baseModel.setSucceed("成功获得该用户里程",mileageList);
        }
    }
}
